import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SheetButtonVO, SheetButtonForm, SheetButtonQuery } from '@/api/sheet/sheetButton/types';

/**
 * 查询应用控件列表
 * @param query
 * @returns {*}
 */

export const listSheetButton = (query?: SheetButtonQuery): AxiosPromise<SheetButtonVO[]> => {
  return request({
    url: '/system/sheetButton/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取所有应用控件
 * @param query
 */
export const listAllSheetButton = (query?: SheetButtonQuery): AxiosPromise<SheetButtonVO[]> => {
  return request({
    url: '/system/sheetButton/listAll',
    method: 'get',
    params: query
  });
};

/**
 * 查询应用控件详细
 * @param sheetFormButtonId
 */
export const getSheetButton = (sheetFormButtonId: string | number): AxiosPromise<SheetButtonVO> => {
  return request({
    url: '/system/sheetButton/' + sheetFormButtonId,
    method: 'get'
  });
};

/**
 * 新增应用控件
 * @param data
 */
export const addSheetButton = (data: SheetButtonForm) => {
  return request({
    url: '/system/sheetButton',
    method: 'post',
    data: data
  });
};

/**
 * 修改应用控件
 * @param data
 */
export const updateSheetButton = (data: SheetButtonForm) => {
  return request({
    url: '/system/sheetButton',
    method: 'put',
    data: data
  });
};

/**
 * 删除应用控件
 * @param sheetFormButtonId
 */
export const delSheetButton = (sheetFormButtonId: string | number | Array<string | number>) => {
  return request({
    url: '/system/sheetButton/' + sheetFormButtonId,
    method: 'delete'
  });
};

/**
 * 修改或保存应用控件
 * @param data
 */
export const addOrUpdateSheetButton = (data: SheetButtonVO[]) => {
  return request({
    url: '/system/sheetButton/addOrUpdateSheetButton',
    method: 'post',
    data: data
  });
};
